package com.zhilianbao.leyaogo.view.popup;

import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.utils.Utils;

import butterknife.ButterKnife;

/**
*余额更多弹窗
 */
public class BalancePopup extends BasePopup {

    private ListView mBalancePopListView;

    public BalancePopup(Activity activity) {
        super(activity);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.view_balance_pop;
    }

    @Override
    public void onCreatePopupView(View view) {
        mBalancePopListView = (ListView) view.findViewById(R.id.balance_pop_list_view);
    }
    public void setBalanceAdapter( ListAdapter adapter) {
        mBalancePopListView.setAdapter(adapter);
    }

    public void initPopupView() {
        View contentView = View.inflate(mActivity, getLayoutResId(), null);
        mPopupWindow = new PopupWindow(contentView,( Utils.getScreenWidth() - Utils.dp2px(12) * 3) / 2,  WindowManager.LayoutParams.WRAP_CONTENT);
        mPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
        mPopupWindow.setFocusable(true);
        mPopupWindow.setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss() {
                WindowManager.LayoutParams attributes = mActivity.getWindow().getAttributes();
                attributes.alpha = 1.0f;
                mActivity.getWindow().setAttributes(attributes);
            }
        });
        ButterKnife.bind(this, contentView);
        onCreatePopupView(contentView);
    }
}
